using System;
using System.Collections.Generic;
using System.Text;
using DDW.Collections;

namespace DDW
{
	public class NamespaceNode : BaseNode
	{
		private NodeCollection<NamespaceNode> namespaces;
		public NodeCollection<NamespaceNode> Namespaces
		{
			get { if (namespaces == null) namespaces = new NodeCollection<NamespaceNode>(); return namespaces; }
			set { namespaces = value; }
		}
		private NodeCollection<ClassNode> classes = new NodeCollection<ClassNode>();
		public NodeCollection<ClassNode> Classes
		{
			get { return classes; }
			set { classes = value; }
		}

		private NodeCollection<EnumNode> enums = new NodeCollection<EnumNode>();
		public NodeCollection<EnumNode> Enums
		{
			get { return enums; }
			set { enums = value; }
		}

		private NodeCollection<DelegateNode> delegates = new NodeCollection<DelegateNode>();
		public NodeCollection<DelegateNode> Delegates
		{
			get { return delegates; }
			set { delegates = value; }
		}

		private NodeCollection<InterfaceNode> interfaces = new NodeCollection<InterfaceNode>();
		public NodeCollection<InterfaceNode> Interfaces
		{
			get { return interfaces; }
			set { interfaces = value; }
		}

		private NodeCollection<StructNode> structs = new NodeCollection<StructNode>();
		public NodeCollection<StructNode> Structs
		{
			get { return structs; }
			set { structs = value; }
		}


		private IdentifierExpression name;
		public IdentifierExpression Name
		{
			get { return name; }
			set { name = value; }
        }

        public override void ToSource(StringBuilder sb)
		{
			if (attributes != null)
			{
				attributes.ToSource(sb);
				this.NewLine(sb);
			}
			if (name != null)
			{
				sb.Append("namespace ");
				name.ToSource(sb);
				NewLine(sb);
				sb.Append("{");
				indent++;
				NewLine(sb);
			}

			if (namespaces != null)
				namespaces.ToSource(sb);

			if(interfaces != null)
				interfaces.ToSource(sb);

			if (classes != null)
				classes.ToSource(sb);

			if (structs != null)
				structs.ToSource(sb);

			if (delegates != null)
				delegates.ToSource(sb);

			if (enums != null)
				enums.ToSource(sb);


			if (name != null)
			{
				indent--;
				NewLine(sb);
				sb.Append("}");
				NewLine(sb);
			}

            
        }
	
	}
}
